<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="GBK">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>空间站-活动列表</title>
    <link rel="stylesheet" href="./css/activity.css">
    <link rel="icon" href="https://sc2.nosdn.127.net/1/style/images/sc2.ico" type="image/x-icon"/>
</head>

<body>
    <div class="nav">
        <ul>
            <li>公告</li>
            <li class="active"><a href="/activity.html">活动</a></li>
            <li>文档</li>
        </ul>
    </div>
    <div id="pageCenter">
        <div class="title">
            <p class="main">《死亡空间站》活动列表</p>
        </div>
        <div id="List">
            <div class="List_image">
                <div class="list_topImage"></div>
                <div class="list_bottomImage"></div>
            </div>
            <ul>
            </ul>
        </div>
    </div>
    <div class="activityBackground">
        <!-- <img src="https://sc2.nosdn.127.net/1/style/v4/common/main_bg_v4.jpg" alt=""> -->
    </div>
    <script>
        let activityList = [
            {name: "【周年庆】我是赞助商!",qq: 2466396619,date: "8-4",cover_url: "https://sc2.nosdn.127.net/images/2021/5/6/2dc303d1524073c57b4ec1f9613d1e66"},
            // {name: "【周年庆】优惠套餐随心选！",qq: 2964019036,date: "8-6",cover_url:"https://sc2.nosdn.127.net/images/2021/2/3/927a831334eed1fed0a11fbd250f31ee"},
            {name: "【周年庆】待定活动",qq: 2964019036,date: "8-6",cover_url:"https://sc2.nosdn.127.net/images/2021/2/3/927a831334eed1fed0a11fbd250f31ee"},
            // {name: "【周年庆】全员狂欢嘻唰唰！",qq: 2964019036,date: "8-6",cover_url:"https://sc2.nosdn.127.net/images/2020/10/15/87c5d2af362b4c3b83eedf9e9dd5a2fe"},
            {name: "【周年庆】待定活动",qq: 2964019036,date: "8-6",cover_url:"https://sc2.nosdn.127.net/images/2020/10/15/87c5d2af362b4c3b83eedf9e9dd5a2fe"},
            // {name: "战场老兵回归令！",qq: 2964019036,date: "8-6",cover_url:"https://sc2.nosdn.127.net/images/2020/7/24/a3898b178036bc7c61719aa764f59cf9"},
            // {name: "开箱大集结！",qq: 2964019036,date: "8-6",cover_url:"https://hearthstone.nosdn.127.net/a/images/2019/12/13/fb2e4dfddb36d75cb10d747fb4969efb.jpg"},
        ]
        // 根据数组自动化创建列表元素
        function initList(){
            let ListUl = document.querySelector("#List>ul");
            for(let i=0;i<activityList.length;i++){
                let memberObj = activityList[i];
                // 创建li
                let li = document.createElement("li");
                let a =document.createElement("a");
                a.href="/sponsor.html";
                // a.setAttribute("h")
                // 创建头像
                let img = document.createElement("img");
                img.src = memberObj.cover_url;
                // 创建信息块
                let info = document.createElement("div");
                info.classList.add("info");
                    // 创建用户名
                    let userName = document.createElement("p");
                    userName.classList.add("userName");
                    userName.innerText = memberObj.name;
                    // 创建用户QQ
                    let userqq = document.createElement("p");
                    userqq.classList.add("qq");
                    userqq.innerText = memberObj.qq;
                    // 创建额度
                    let usermoney = document.createElement("p");
                    usermoney.classList.add("money");
                    usermoney.innerText = memberObj.quota + "￥";
                // 创建排行序号
                let userindex = document.createElement("div");
                userindex.classList.add("index");
                userindex.innerText = i+1;
                // 整合元素
                info.appendChild(userName);
                // info.appendChild(userqq);
                // info.appendChild(usermoney);
                a.appendChild(img);
                a.appendChild(info);
                li.appendChild(a);
                // li.appendChild(userindex);
                ListUl.appendChild(li);
            }

        }

        let memberRant = [];
        // 合并记录至QQ为单位下的数据
        function initRant(){
            // 检索所有记录
            for (let index = 0; index < memberMoney.length; index++) {
                let member = memberMoney[index];
                let isExist = false;
                // 检索现有排行是否已经有记录
                for (let j = 0; j < memberRant.length; j++) {
                    let rant = memberRant[j];
                    if(rant.qq == member.qq){
                        rant.quota += member.quota;
                        isExist = true;
                        break;
                    }
                }
                if(!isExist){
                    memberRant.push(member);
                }
            }
        }
        // 对赞助数据进行排序
        function initRantSort(){
            memberRant = memberRant.sort(function(a,b){
                return  b.quota - a.quota;
            })
        }
        // initRant();
        // initRantSort();
        initList();
    </script>
</body>

</html>